home *** CD-ROM | disk | FTP | other *** search
/ Aminet 12 / Aminet 12 (1996)(GTI - Schatztruhe)[!][Jun 1996].iso / Aminet / dev / misc / FidoLib.lha / FidoLib / fidonet.c next >
Encoding:
C/C++ Source or Header  |  1996-03-20  |  1.7 KB  |  73 lines

  1. /* fidonet.c */
  2.  
  3. #include "sh/sub.h"
  4. #include "exec/io.h"
  5. #include "exec/memory.h"
  6. #include "exec/libraries.h"
  7. #include "exec/execbase.h"
  8. #include "dos/dos.h"
  9. #include "dos/dostags.h"
  10. #include "fidonet.h"
  11. #include "proto/exec_protos.h"
  12. #include "proto/dos_protos.h"
  13.  
  14. #define TRUE 1
  15. #define FALSE 0
  16.  
  17. int _main(void);
  18. void error(u_char *),cleanup(void);
  19.  
  20. struct RdArds *ra;
  21.  
  22. ULONG args[2];
  23.  
  24. /* These are required by fidonet.lib. */
  25.  
  26. u_char DayBuf[48],DateBuf[48],TimeBuf[48];
  27. struct DateTime timedate = { 0,0,0,FORMAT_DOS,0,DayBuf,DateBuf,TimeBuf };
  28. struct DateStamp ds;
  29.  
  30. u_char template[]="",ver[]="$VER: fidonet packet demo program 1.00",cmd[32],
  31.     buf[128],secbuf[128];
  32.  
  33. /* This is a little demo to show you how to use fidonet.lib. */
  34.  
  35. int _main(void) {
  36. LONG i;
  37. BPTR pkt;
  38.  
  39.     /* This is required by fidonet.lib. Also provide the buffer needed. */
  40.  
  41.     GetProgramName(cmd,32);
  42.  
  43.     if(!(ra=ReadArgs(template,args,NULL))) {
  44.         PrintFault(i=IoErr(),cmd);
  45.         exit(i);
  46.     }
  47.     sprintf(buf,"T:%08lx.PKT",clock());
  48.     pkt=MakePkt(buf,"65:10/5","65:10/1","password");
  49.     MakeMsg(pkt,"20 Mar 96  18:30:20",0);
  50.     Write(pkt,"All",4);
  51.     Write(pkt,"Sami Klemola",13);
  52.     Write(pkt,"fidonet.lib",12);
  53.     Write(pkt,"This is a library that provides easy\rmeans to creating fidonet packets.\r",73);
  54.     ClosePkt(pkt);
  55.     printf("Written %s.\n",buf);
  56.     cleanup();
  57.     return(RETURN_OK);
  58. };
  59.  
  60. /* You MUST provide these functions when using fidonet.lib. When something
  61.    it tries fails, it will call error() or cleanup() and then exit(). */
  62.  
  63. void error(u_char *str) {
  64.     printf("%s: %s\n",cmd,str);
  65.     cleanup();
  66.     exit(RETURN_FAIL);
  67. };
  68.  
  69. void cleanup(void) {
  70.     if(ra) FreeArgs(ra);
  71. };
  72.  
  73.